Repository navigation
Conversation
- PasswordBcryptMapper is UserModel's default: a 60-character hash is bcrypt, a 40-character one SHA-1, so existing users keep logging in; new and changed passwords get bcrypt - PasswordMapperInterface: verifyPassword() and needsRehash(); isValidUser() verifies with the mapper instead of comparing hashes with === - UserModel::setPassword() asks the mapper whether a value is a hash (was strlen != 40) - PasswordSha1Mapper stays selectable and compares with hash_equals()
- isValidUser() only checks the password - UsersService::rehashPasswordIfNeeded() replaces an older hash (SHA-1, or bcrypt with a lower cost); createAuthToken() calls it at login - It reads the new hash back and keeps the old one when the column is too short for it (rejected or truncated), so nobody is locked out before the column is widened
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
PasswordBcryptMapperisUserModel's default. New and changed passwords are hashed with bcrypt. It also verifies the 40-character SHA-1 hashes ofPasswordSha1Mapper, so existing users keep logging in.UsersService::rehashPasswordIfNeeded()replaces an older hash (SHA-1, or bcrypt with a lower cost) once the password is known;createAuthToken()calls it.isValidUser()only checks the password.false, so nobody is locked out before the column is widened.PasswordMapperInterfacegainsverifyPassword()andneedsRehash();isValidUser()uses them instead of comparing hashes with===.PasswordSha1Mapperstays selectable and compares withhash_equals().UserModel::setPassword()asks the mapper whether a value is already a hash (it skipped the password definition for any 40-character value).Breaking changes (see
CHANGELOG-7.0.md)VARCHAR(255).verifyPassword()andneedsRehash().UsersServiceInterfacehasrehashPasswordIfNeeded().Tests
PasswordBcryptMapperTestandPasswordUpgradeTest(SHA-1 user upgraded at login, wrong password not upgraded, a column that rejects or truncates the hash keeps SHA-1 and the user still logs in, a stored hash not checked against the password definition). Each part of the safety net was checked to fail its test when removed. PHPUnit 182 tests and Psalm pass.